Skip to content

Handle interrupts in tests#2148

Merged
hadley merged 4 commits into
mainfrom
test-interrupt
Aug 5, 2025
Merged

Handle interrupts in tests#2148
hadley merged 4 commits into
mainfrom
test-interrupt

Conversation

@hadley
Copy link
Copy Markdown
Member

@hadley hadley commented Jul 31, 2025

I don't see any way to test this programmatically, so I've been testing by adding Sys.sleep(10) to a random test.

Fixes #1464

I don't see any way to test this programmatically, so I've just been adding `Sys.sleep(10)` to a random test.

Fixes #1464
@hadley hadley requested a review from lionel- July 31, 2025 20:36
Comment thread R/reporter-stop.R

initialize = function(stop_reporter = TRUE, praise = TRUE) {
super$initialize()
self$failures <- Stack$new()
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a refactoring I included in this PR because it was confusing me — failures did not just track failing expectations, but all expectations that we need to inform the user about.

Comment thread R/reporter-stop.R
messages <- vapply(failures, issue_summary, rule = TRUE, character(1))
if (length(messages) > 0) {
if (self$issues$size() == 0) {
if (self$praise && self$n_success > 0) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key change is to only report success if there was one actual success — normally if there are zero successes you'll get a skip, but that doesn't help with interrupts. (I also tried emitting a skip, but I think that adds additional unneeded noise).

@hadley hadley merged commit 1154cbf into main Aug 5, 2025
10 of 11 checks passed
@hadley hadley deleted the test-interrupt branch August 5, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mention current test on interrupt

2 participants